package com.ming.springboot.config.mongodb;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.MongoTemplate;

/**
 * Created by mqsi on 2022/5/20 16:45
 */
@Configuration
public class MongoManager {
	@Autowired
	MongoTemplate mongoTemplate;

	public MongoTemplate getMongoTemplate(){
		return mongoTemplate;
	}

	public void add(Object obj){
		mongoTemplate.save(obj);
	}

	public <T> T findByPk(String strPk, Class<T> clazz){
		return mongoTemplate.findById(strPk, clazz);
	}
}
